class Solution(object):
    def isIsomorphic(self, s, t):
        """
        :type s: str
        :type t: str
        :rtype: bool
        """
        s_to_t = {}
        t_to_s = {}
        for x, y in zip(s, t):
            if x not in s_to_t:
                s_to_t[x] = y
            else:
                if s_to_t[x] != y:
                    return False
            
            if y not in t_to_s:
                t_to_s[y] = x
            else:
                if t_to_s[y] != x:
                    return False
        return True
if __name__ == '__main__':
    s = "egg"
    t = "add"
    print(Solution().isIsomorphic(s, t))
# 思路：
# 一一映射只需要建立两个字典对应关系进行，即双向对应